package com.miyake.client;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.miyake.client.admin.UserManagement;

public class TopPage extends Composite {
	protected DoctorsUserServiceAsync service = DoctorsUserService.Util.getInstance();

	public TopPage() {
		final VerticalPanel verticalPanel = new VerticalPanel();
		initWidget(verticalPanel);
		verticalPanel.setWidth("700px");
		service.isAdministrator(new AsyncCallback<Boolean>() {
			@Override
			public void onFailure(Throwable caught) {
			}

			@Override
			public void onSuccess(Boolean result) {
				if (result.equals(true)) {
					verticalPanel.add(new HTML("<h1>Administration</h1>"));
					verticalPanel.add(new UserManagement());
				}
				else {
					Label title = new Label("PHASEBOOK");
					title.setStylePrimaryName("bigTitle");
					verticalPanel.add(title);
					verticalPanel.add(new HTML("<h1>Phasebook helps you connect and share with the people in your life.</h1>"));			
				}
			}
		});
	}

}
